import request from '@/config/axios'

// 销售 VO
export interface SaleVO {
  id: string // 主键
  commodity: string // 商品
  company: string // 公司名称
  count: string // 数量
  createAt: string // 创建时间
  description: string // 备注
  number: string // 打款账号
  pay: boolean // 结款是否完成true/false
  phone: string // 预留电话
  price: number // 总计
}

// 销售 API
export const SaleApi = {
  // 查询销售分页
  getSalePage: async (params: any) => {
    return await request.get({ url: `/wms/sale/page`, params })
  },

  // 查询销售详情
  getSale: async (id: string) => {
    return await request.get({ url: `/wms/sale/get?id=` + id })
  },

  // 新增销售
  createSale: async (data: SaleVO) => {
    return await request.post({ url: `/wms/sale/create`, data })
  },

  // 修改销售
  updateSale: async (data: SaleVO) => {
    return await request.put({ url: `/wms/sale/update`, data })
  },

  // 删除销售
  deleteSale: async (id: string) => {
    return await request.delete({ url: `/wms/sale/delete?id=` + id })
  },

  // 导出销售 Excel
  exportSale: async (params) => {
    return await request.download({ url: `/wms/sale/export-excel`, params })
  },

  // 结款
  settleSale: async (id: string) => {
    return await request.put({ url: `/wms/sale/settle/` + id })
  },
}
